//const http = 'http://127.0.0.1:8080';
const http = 'http://120.78.130.131:8080';
function wxRequest(url, data, callback) {
  $.ajax({
    url: http + url,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'X-Requested-With': 'XMLHttpRequest',
//    'userkey': sessionStorage.getItem("userkey") //单会话，只能一个窗口访问
      'userkey': localStorage.getItem("userkey")  //多会话，本地多个窗口访问
    },
    xhrFields: { withCredentials: true },
    method: 'POST',
    data: data,
    success(e,req,resp) {
      if (resp.status == 200) {
        if (e.code=="success"){
          if(e.msg!=''&&e.msg!=null&&e.msg!=undefined){
            layer.msg(e.msg,{icon: 1,time: 2000},function(){
            	typeof callback == "function" && callback(e);
            });
          }else{
          	typeof callback == "function" && callback(e);
          }
        }else{
          layer.msg(e.msg,{icon: 2,time: 2000 }); //2秒关闭
          console.log(e);
        }
      } else if (resp.status == 401) {
        // callbackLogin();
         layer.confirm(str, {btn: ['确定', '取消'], title: "提示"}, function () {
         	 login();
         });
      } else {
      	layer.msg('系统繁忙',{icon: 2});
      }  //end if
    },
    error(req) {
    	if (req.status == 401) {
         layer.confirm(req.responseJSON.msg, {btn: ['确定', '取消'], title: "提示"}, function () {
         	 login();
         });
      } else {
      	layer.msg('系统繁忙',{icon: 2});
      }  //end if
    }
  });
};
function login(){
   location.href = "login.html";
}